<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp" %>
<!DOCTYPE>
<html>
  <head>
    <base href="<%=basePath %>">
    <title>Untitled</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<%@include file="/views/global/ShopInclude.jsp" %>
	
<link rel="stylesheet" type="text/css" href="static/css/page/internalTestPost.css" />
  </head>
  
  <body>
		<!-- <div class="arealeft">
			上传区域
			<div class="addImageArea">
				<form id="imageForm" method="post" enctype="multipart/form-data">
					<input id="addImageFile" name="addImage" class="addImage" type="file" accept="img/*" />
				</form>
			</div>
			上传区域
			图片显示区域
			<div class="showImagesAdded">
				<div class="showImageArea"><img src="static/images/module/image_upload/imageAddBlank.png" blank="true"/></div>
				<div class="showImageArea"><img src="static/images/module/image_upload/imageAddBlank.png" blank="true"/></div>
				<div class="showImageArea"><img src="static/images/module/image_upload/imageAddBlank.png" blank="true"/></div>
				<div class="showImageArea"><img src="static/images/module/image_upload/imageAddBlank.png" blank="true"/></div>
			</div>
			图片显示区域
		</div> -->
		<form id="postForm" class="form-horizontal validate" method="post" role="form">
		<input type="hidden" name="subjectId" value="${subjectId }"/>
		<div class="arearight" style="height: 326px;margin-top: 0;">
			<ul>
				<li>
					<textarea class="font" rows="5" cols="5" name="content" placeholder="输 入 TEXT..." style="margin-left: 32px;height: 283px;"></textarea>
				</li>
				<li class="planeli">
					<div id="msg"></div>
					<a href="javascript:void(0)" onclick="saveNode(this)">
						<img src="static/images/page/internalTestPost/icon-plane-orange.png" class="icon-plane-orange">
					</a>
				</li>
			</ul>
		</div>
		</form>
	
	
 	<%@include file="/views/global/AdminScripts.jsp" %>
  </body>
<script type="text/javascript">
$(document).ready(function(){
	$("#addImageFile").on("change", function(){
		var target = this;
		if("" != $.trim($(target).val())){
			if(0 == $(".showImagesAdded").find("IMG[blank='true']")){
				return false;
			}
			$("#imageForm").goAjax({
				url:"/upload",
				semantic:false,
				data:{},
				success: function(jsonData) {
					if("SUCCESS" == jsonData.state){
						var imgObj = $(".showImagesAdded").find("IMG[blank='true']").eq(0);
						$(imgObj).attr("src", jsonData.url);
						$(imgObj).attr("blank", false);
					}
					$(target).val("");
				}
			});
		}
	});
});

function saveNode(target){
	var form = $("#postForm");
	var validator = $(form).validate({meta:"validate"});
	if(validator.form()){
		var attArray = new Array();
		$(".showImagesAdded").find("IMG[blank='false']").each(function(i, obj){
			attArray.push($(obj).attr("src"));
		});
		$(form).goAjax({
			url:"general/advice/saveReply",
			semantic:false, checkLogin: true,
			data:{attachments: attArray.join(",")},
			success: function(jsonData) {
				if(true == jsonData.success){
					art.dialog.data("refresh.now", true);
					art.dialog.close();
				} else {
					$("#msg").alert({type:'alert-danger', text: jsonData.message});
				}
			}
		});
	}
}
</script>
</html>
